<template>
  <div>
    <div
      class="form-group mt15"
      v-for="(value, key) in $store.state.edit.row.exportFields"
    >
      <label class="col-sm-2 control-label">{{ m(value) }}</label>
      <div class="col-sm-10">
        <el-select
          size="mini"
          v-model="ruleValues[rule.field]"
          filterable
          clearable
          :multiple="true"
        >
          <el-option
            v-for="k in Object.keys(
              $store.state.edit.entry.sources['roleSource']
            )"
            :key="k"
            :label="m($store.state.edit.entry.sources['roleSource'][k])"
            :value="k"
          >
          </el-option>
        </el-select>
      </div>
    </div>
  </div>
</template>

<script>
import { m } from "@/store/yg/common/local";

export default {
  data() {
    return {
      ruleValues: {}
    };
  },
  props: ["field"],
  methods: {
    init() {
      if (this.$store.state.edit.row["permissionExportJson"]) {
        this.ruleValues = JSON.parse(
          this.$store.state.edit.row["permissionExportJson"]
        );
      }
      for (var k in this.$store.state.edit.row.exportFields) {
        if (!this.ruleValues[k]) {
          this.ruleValues[k] = [];
        }
      }
    },
    m(k) {
      return m(k);
    },
    callbefore() {
      this.$store.state.edit.row["permissionExportJson"] = JSON.stringify(
        this.ruleValues
      );
    }
  }
};
</script>
